// 模拟消息数据
const mockMessages = [
  {
    id: 1,
    content: '你好',
    time: Date.now() - 3600000,
    isSelf: false,
    status: 'sent' // sent, sending, failed
  },
  {
    id: 2,
    content: '你好啊',
    time: Date.now() - 3500000,
    isSelf: true,
    status: 'sent'
  },
  {
    id: 3,
    content: '最近在忙什么呢？',
    time: Date.now() - 3400000,
    isSelf: false,
    status: 'sent'
  },
  {
    id: 4,
    content: '在写代码，你呢？',
    time: Date.now() - 3300000,
    isSelf: true,
    status: 'sent'
  },
  // ... 更多消息
]

// 模拟延迟
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))

// 获取历史消息
export const getHistoryMessages = async (page: number, pageSize: number = 20) => {
  await delay(1000)
  const start = (page - 1) * pageSize
  const end = start + pageSize
  const hasMore = start < mockMessages.length
  
  return {
    messages: hasMore ? mockMessages.slice(start, end).reverse() : [],
    hasMore
  }
}

// 发送消息
export const sendMessage = async (content: string) => {
  await delay(500)
  return {
    id: Date.now(),
    content,
    time: Date.now(),
    isSelf: true,
    status: 'sent'
  }
} 